package com.hualan.zhsq.service.impl.car;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hualan.zhsq.entity.car.ParkingStatus;
import com.hualan.zhsq.mapper.car.ParkingStatusMapper;
import com.hualan.zhsq.service.car.ParkingStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName ParkingStatusServiceImpl
 * @Description 停车位状态serviceImpl
 * @Author ZheRan
 * @Date 2025年08月04日 下午7:02
 * @Version 1.0
 */
@Service("parkingStatusService")
public class ParkingStatusServiceImpl implements ParkingStatusService {

    @Autowired
    private ParkingStatusMapper parkingStatusMapper;

    @Override
    public int add(ParkingStatus entity) {
        return parkingStatusMapper.insert(entity);
    }

    @Override
    public int edit(ParkingStatus entity) {
        return parkingStatusMapper.updateById(entity);
    }

    @Override
    public int remove(Integer id) {
        return parkingStatusMapper.deleteById(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return parkingStatusMapper.deleteBatchIds(List.of(ids));
    }

    @Override
    public List<ParkingStatus> find() {
        return parkingStatusMapper.selectList(null);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, ParkingStatus entity) {
        Page<ParkingStatus> page = new Page<>(pageNum,pageSize);
        Page<ParkingStatus> parkingStatusPage = parkingStatusMapper.selectPage(page, null);
        Map<String, Object> map = new HashMap<>();
        map.put("list",parkingStatusPage.getRecords());
        map.put("total",parkingStatusPage.getTotal());
        map.put("size",parkingStatusPage.getSize());
        return map;
    }

    @Override
    public ParkingStatus findById(Integer id) {
        return parkingStatusMapper.selectById(id);
    }
}
